
{% extends "base.html" %}

{% block content %}
<div class="dashboard">
    <div class="card">
        <h2>快捷操作</h2>
        <a href="/add/" class="btn">添加新食品</a>
        <a href="/scan/" class="btn">扫码查询</a>
    </div>
    <div class="card">
        <a href="{% url 'expired_foods' %}" class="stat-item expired">
            <h2>已过期</h2>
            <p>{{ stats.expired_count }} 件</p>
        </a>
        <a href="{% url 'expiring_foods' %}" class="stat-item expiring">
            <h2>即将过期（7天内）</h2>
            <p>{{ stats.expiring_soon_count }} 件</p>
        </a>
    </div>
</div>

<style>
.dashboard {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 20px;
}
.card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.btn {
    display: block;
    background: #4CAF50;
    color: white;
    padding: 10px;
    margin: 10px 0;
    text-align: center;
    text-decoration: none;
}
.alert {
    padding: 10px;
    margin: 5px 0;
    border-radius: 4px;
}
.expired { background: #ffebee; color: #c62828; }
.warning { background: #fff3e0; color: #ef6c00; }
</style>
{% endblock %}